{extend name="$_admin_layout"}

{block name="tpl_vars"}
    {assign name="page_title" value="菜单管理" /}
{/block}

{block name="main-content"}
    <form id="menu_list" class="table-form table-manager">
        <div class="box box-blue">
            <div class="box-body">
            
                <input type="hidden" name="mp_id" value="{$mp_id}" />
            
                <div class="row">
                    <div class="col-sm-8">
                        <div class="table-fixed-toolbar">
                            {include file='wechat@admin/common/mp_list'}
                            {:helper('admin/toolbar')->render_button('新建', 'fa fa-plus', 'btn btn-primary form-get', array('url' => $_controller->url('create')))}
                            {:helper('admin/toolbar')->render_button('上传', 'fa fa-upload', 'btn btn-primary ajax-post', array('url' => $_controller->url('upload')))}
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="table-fixed-toolbar pull-right">
                            {:helper('admin/toolbar')->render_button('', 'fa fa-question', 'btn btn-default', array('data-toggle' => 'modal', 'data-target' => '#custom-menu-help'))}
                        </div>
                    </div>
                </div>
     
                <div class="row">
                    <div class="col-sm-12">
                       <table class="table table-bordered table-striped table-hover treegrid">
                           <thead>
                               <tr>
                                   <th>{:helper('admin/table')->render_header_text('标题')}</th>
                                   <th>{:helper('admin/table')->render_header_text('排序')}</th>
                                   <th>{:helper('admin/table')->render_header_text('状态')}</th>
                                   <th>{:helper('admin/table')->render_header_text('操作')}</th>
                               </tr>
                           </thead>
                           <tbody>
                               {notempty name="menu_list"}
                                   {foreach name="menu_list" item="vo"}
                                       <tr class="treegrid-{$vo.id} <?php if ($vo['pid']): ?> treegrid-parent-{$vo.pid}<?php endif; ?>">
                                           <td>{:helper('admin/table')->render_column_text($vo['title'])}</td>
                                           <td>{:helper('admin/table')->render_column_text($vo['sort'])}</td>
                                           <td>{:helper('admin/table')->render_column_status($vo['status'])}</td>
                                           <td>
                                               {:helper('admin/table')->render_action('修改', 'fa fa-edit', 'btn btn-primary btn-xs form-get', array('url' => $_controller->url('modify', array('id' => $vo['id']))))}
                                               {:helper('admin/table')->render_action('删除', 'fa fa-trash', 'btn btn-danger btn-xs ajax-post', array('url' => $_controller->url('delete', array('id' => $vo['id'])), 'confirm-text' => '确定删除选择的数据吗？'))}
                                           </td>
                                       </tr>
                                   {/foreach}
                               {else /}
                                   {:helper('admin/table')->render_empty_row()}
                               {/notempty}
                           </tbody>
                       </table>
                   </div>
               </div>

            </div><!-- /.box-body -->
        </div><!-- /.box -->
    </form>
    
    <div class="modal fade" id="custom-menu-help">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">自定义菜单</h4>
                </div>
                <div class="modal-body">
                    <p>
                        <p>自定义菜单能够帮助公众号丰富界面，让用户更好更快地理解公众号的功能。</p>
                        <p>1、自定义菜单最多包括3个一级菜单，每个一级菜单最多包含5个二级菜单。</p>
                        <p>2、一级菜单最多4个汉字，二级菜单最多7个汉字，多出来的部分将会以“...”代替。</p>
                        <p>3、创建自定义菜单后，菜单的刷新策略是，在用户进入公众号会话页或公众号profile页时，如果发现上一次拉取菜单的请求在5分钟以前，就会拉取一下菜单，如果菜单有更新，就会刷新客户端的菜单。测试时可以尝试取消关注公众账号后再次关注，则可以看到创建后的效果。</p>
                        <p>更多关于自定义菜单的详细详细，请参考<a href="https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141013" target="_blank">《微信公众平台技术文档》</a></p>
                    </p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>
{/block}
